package com.codeczx.myretrofitdemo.retrofit;

/**
 * Created by codeczx on 2018/3/26.
 */

abstract class ParameterHandler<T> {


    public abstract void apply(RequestBuilder requestBuilder, T args);

    static final class Path<T> extends ParameterHandler<T>{

        private final String name;
        private final Converter<T,String> valueConverter;
        private final boolean encoded;

        Path(String name, Converter<T,String> valueConverter, boolean encoded){
            this.name = name;
            this.valueConverter = valueConverter;
            this.encoded = encoded;
        }

        @Override
        public void apply(RequestBuilder builder , T value) {
            builder.addPathParam(name,valueConverter.convert(value),encoded);
        }
    }
}
